package personal.hn.newjava.controller;

import personal.hn.newjava.common.result.TableDataInfo;
import personal.hn.newjava.model.Goods;
import personal.hn.newjava.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/goods")
public class GoodsController {
    @Autowired
    GoodsService goodsService;
    /**
     *
     */
    @GetMapping("/list")
    public TableDataInfo list(Goods goods, Pageable page) {
        int pageNum = page.getPageNumber() - 1;
        pageNum = pageNum <= 0 ? 0 : pageNum;
        page = PageRequest.of(pageNum, page.getPageSize());
        return goodsService.selectGoodsList(goods, page);
    }
}
